<template>
    <el-dialog :title="title" :visible.sync="open" width="60%" destroy-on-close append-to-body>
        <el-form :model="formData" size="small" label-width="120px" ref="form">
            <el-row>
                <el-col :span="12">
                    <el-form-item label="任务内容" prop="cate">
                        {{ formData.taskContent }}
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="12">
                    <el-form-item label="辅助信息" prop="cate">
                        {{ formData.helpContent }}
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row v-if="formData.status == 2">
                <el-col :span="12">
                    <el-form-item label="反馈内容" prop="cate">
                        {{ formData.submit }}
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row v-if="formData.attachs && formData.attachs.length > 0">
                <el-col :span="12">
                    <el-form-item label="任务附件" prop="cate">
                        <uploader :files="formData.attachs" :canUpload="false" @onDownload="handleTaskAttachDownload" width="80px" />
                    </el-form-item>
                </el-col>
            </el-row>
        </el-form>
        <div slot="footer" class="dialog-footer">
            <el-button type="primary" @click="close">确 定</el-button>
        </div>
    </el-dialog>
</template>

<script>
import dialogMixin from "@/mixins/dialogMixin";
import Uploader from "@/views/components/uploader/index.vue";
import { getTaskInfo } from "@/api/drill/task";

export default {
    name: "TaskDetailDialog",
    mixins: [dialogMixin],
    components: { Uploader },
    data() {
        return {
            title: "任务详情",
            open: false,
            formData: {
                attachs: [],
            },
            uploadinglist: [],
        };
    },
    methods: {
        //完成任务调
        showDialog(data) {
            this.getInfo(data.taskId);
        },
        getInfo(taskId) {
            getTaskInfo(taskId).then(res => {
                this.formData = res.data;
                this.open = true;
            });
        },
        handleTaskAttachDownload(row) {
            // 下载附件
            this.download(`com/ComAttach/download/${row.attachid}`, {}, `${row.attachname}.${row.attachtype}`);
        },
    },
};
</script>

<style lang="scss" scoped>
.task-report {
    padding: 0 20px 20px;
}
</style>
